/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.stu.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author sy
* @date 2020-12-25
**/
@Entity
@Data
@Table(name="stu")
public class Stu implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "学生编号")
    private Long id;

    @Column(name = "sname",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "学生姓名")
    private String sname;

    @Column(name = "sex",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "性别")
    private String sex;

    @Column(name = "age",nullable = false)
    @NotNull
    @ApiModelProperty(value = "年龄")
    private Long age;

    @Column(name = "phone",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "电话号码")
    private String phone;

    @Column(name = "password",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "密码")
    private String password;

    @Column(name = "head")
    @ApiModelProperty(value = "用户头像")
    private String head;

    @Column(name = "hobbyid",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "爱好id")
    private String hobbyid;

    @Column(name = "remaining")
    @ApiModelProperty(value = "个人余额")
    private BigDecimal remaining;

    @Column(name = "courseid")
    @ApiModelProperty(value = "课程编号")
    private String courseid;

    @Column(name = "introduce")
    @ApiModelProperty(value = "个人简介")
    private String introduce;

    public void copy(Stu source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}